package com.cnswhy.cloud.server.comsumer.schedule;

import com.cnswhy.cloud.common.core.utils.SystemClockUtil;
import com.cnswhy.cloud.common.redis.service.RedisService;
import com.cnswhy.cloud.server.core.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ConfigureTimer {
    @Autowired
    SysConfigService sysConfigService;
    @Scheduled(cron = "0 0/5 * * * ?")
    public void syncConfigure(){
        log.info("同步配置：{}", SystemClockUtil.getLocalDateTime());
        sysConfigService.init();
    }

    @Autowired
    RedisService redisService;
    /*@Autowired
    ShopProductStockService shopProductStockService;
    @Scheduled(cron = "0 0 0/1 * * ?")
    public void syncShopProductStock(){
        List<ShopProductStock> shopProductStocks = shopProductStockService.list();
        for(ShopProductStock shopProductStock : shopProductStocks){
            int stockNum = redisService.hgetInt(RedisConstant.SHOP_PRODUCT_STOCK, shopProductStock.getId() + "");
            if(stockNum == 0 && shopProductStock.getStock() != null){
                redisService.hsetInt(RedisConstant.SHOP_PRODUCT_STOCK, shopProductStock.getId() + "", shopProductStock.getStock());
            }
        }
    }*/
}
